package com.example.demo.service;

import com.example.demo.excelOperate.FileInput;
import com.example.demo.valueObject.AntiCounterfeiting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Search {
    @Autowired
    private FileInput fileInput;

    public Object SearchById(String id)
    {
        List<AntiCounterfeiting> antiCounterfeitings =  fileInput.readExcel();
        int rows = 1;
        for(AntiCounterfeiting a:antiCounterfeitings)
        {
            if(a.getId().equals(id))
            {
                fileInput.writeExcel(rows);
                return a;
            }
            rows++;
        }
        return "查无此产品";
    }
}
